﻿
using Maticsoft.BLL;
using Maticsoft.Model;

using System;
using System.Text;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class WebPage_YingXiao_ShujuXiazai : MarketBBasePage
{

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "yingxiao";
        this.YingXiao1.Select = "shuju";
        if (!base.IsPostBack)
        {
            this.setUpload();
        }
        if ((base.Request.HttpMethod == "POST") && (base.Request.Form["city_id"] != null))
        {
            string id = base.Request.Form["city_id"].ToString();
            this.xiazai(id);
        }
    }

    private void setUpload()
    {
        StringBuilder builder = new StringBuilder();
        Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
        foreach (Maticsoft.Model.Category category2 in category.GetModelList("Zone='city'"))
        {
            builder.Append(string.Concat(new object[] { "<input type='checkbox' name='city_id' value='", category2.Id, "' checked />&nbsp;", category2.Name, "&nbsp;&nbsp;" }));
        }
        this.Literal1.Text = builder.ToString();
    }

    private void xiazai(string id)
    {
        StringBuilder builder = new StringBuilder();
        Maticsoft.BLL.UserInfo info = new Maticsoft.BLL.UserInfo();
        builder.Append("<html>");
        builder.Append("<meta http-equiv=content-type content=\"text/html; charset=UTF-8\">");
        builder.Append("<body><table border='1'>");
        builder.Append("<tr class='alt'>");
        builder.Append("<td>ID</td>");
        builder.Append("<td>用户Email</td>");
        builder.Append("<td>真实姓名</td>");
        builder.Append("<td>手机号码</td>");
        builder.Append("</tr>");
        int num = 0;
        foreach (Maticsoft.Model.UserInfo info2 in info.GetModelList("City_id in (" + id + ")"))
        {
            if ((num % 2) == 0)
            {
                builder.Append("<tr>");
            }
            else
            {
                builder.Append("<tr class='alt'>");
            }
            num++;
            builder.Append("<td align='left'>" + info2.Id + "</td>");
            builder.Append("<td align='left'>" + info2.Email + "</td>");
            builder.Append("<td align='left'>" + info2.Realname + "</td>");
            builder.Append("<td align='left'>" + info2.Mobile + "</td>");
            builder.Append("</tr>");
        }
        builder.Append("</table></body></html>");
        base.Response.ClearHeaders();
        base.Response.Clear();
        base.Response.Expires = 0;
        base.Response.Buffer = true;
        base.Response.AddHeader("Accept-Language", "zh-tw");
        base.Response.AddHeader("content-disposition", "attachment; filename=" + HttpUtility.UrlEncode("mobile_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls", Encoding.UTF8));
        base.Response.ContentType = "Application/octet-stream";
        base.Response.Write(builder.ToString());
        base.Response.End();
    }
}

